define([
  'text!templates/map/controls/searchBar.html',
], function (HTMLTemplate) {

    var view = Backbone.View.extend({
        el: $("#main-content"),
        render: function () {

            var template = Handlebars.compile(HTMLTemplate);
            var html = template();
            this.$el.html(html);

            this.addHandlers();

        },
        addHandlers: function () {
            var _this = this;

            this.$el.find("input").on("keypress", function (e) {
                if (e.which == 13) {
                    _this.$el.find(".btnGeoSearch").trigger("click");
                }
            });


            this.$el.find(".btnGeoSearch").on("click", function () {
                var address = $(this).parent().find("input").val();
                $("#projectMap").trigger("geoSearch", [address]);
            });

        }
    });
    return view;
});